-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(analyzer): improvements to reporting and circular $ref discovery #723
Conversation
* | ||
* @private | ||
*/ | ||
cb?: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having this option here just for testing purposes but because I changed way we use @readme/json-schema-ref-parser
to instantiate it with a class constructor it's really hard with Jest to spy on new $RefParser.dereference()
now to ensure that it's only ever called once.
Adding this callback in here, and then calling it in the .then()
below replicates this behavior.
// with the schema path (file path, url, whatever) that the schema exists in. Because | ||
// we don't care about this information for this reporting mechanism, and only the | ||
// $ref pointer, we're removing it. | ||
return `#${pointer.split('#')[1]}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example pointer coming back from json-schema-ref-parser
looks like /path/to/file.yaml#/components/schemas/name
. We only need the latter part so that's what this is doing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few small nits but otherwise LGTM!
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
🧰 Changes
$ref
schema pointer (one that's prefixed with a#
).$ref
pointers to us when they're discovered during dereferencing. feat: surfacing circular $refs in a newcircularRefs
property on the parser json-schema-ref-parser#58Oas.getCircularReferences()
method that will use the afformetioned API to return a list of every circular$ref
that exists within the API definition.Finally, I've updated the
circularRefs
OpenAPI analyzer query to use these new APIs so it returns exactly what circular$ref
s exist within an API definition, and not all$ref
s that still remain in the API definition after dereferencing:Footnotes
What's the analyzer? It's the new JSONPath query system I've been building for the new
openapi:uses
command in rdme. ↩